/**
* Created by houlei on 2024/10/17.
* */
#include "AppDelegate.h"
#include "GlobalParameters.h"
#include <string>
#include "Simu/Simu.h"
#include "Spot/Spot.h"
#include "Track/Track.h"
#include "EthernetWriter.h"
#include "Task1/Task1.h"
#include "MyDeviceReader/MyDeviceReader.h"
#include "Task2/Task2.h"
#include "Task3/Task3.h"
#include "PythonTask/PythonTask.h"

void AppDelegate::onConfigure(device_config_t *config){
    config->calculationPoolSize=8;
    config->globalParametersInstance = GlobalParameters::shareInstance();
    config->deviceId=3;
    config->servicePort=31112;
    config->ip="192.168.1.81";
    config->userVersion="4.329";
}

void AppDelegate::onStart(){
    REGISTER_RUNTIME_LOADED_CLASSES(Simu,MyDeviceReader,Spot,Track,Task1,Task2,Task3,PythonTask);
    auto simu = new Simu();
    auto spot = new Spot();
    auto track = new Track();
    auto task1 = new Task1();
    auto task2 = new Task2();
    auto task3 = new Task3();
    auto pythontask = new PythonTask();

    spot->addOutput(0,0,track,1000000);
    simu->addOutput(0,0,pythontask,2000000);
    pythontask->addOutput(0,0,spot,2000000);

    auto radarlabWriter_3 = new EthernetWriter(UDP,"192.168.1.119",11999,false);
    task3->addDeviceWriter(0,radarlabWriter_3,10000);

    auto radarlabWriter_1 = new EthernetWriter(UDP,"192.168.1.103",11999,false);
    spot->addDeviceWriter(1,radarlabWriter_1,10000);

    auto radarlabWriter_2 = new EthernetWriter(UDP,"192.168.1.103",11999,false);
    track->addDeviceWriter(0,radarlabWriter_2,10000);

    auto radarlabReader = new MyDeviceReader();
    radarlabReader->addTaskModule(simu,0,1);
    REGISTER_INSTANCES(simu,radarlabReader,spot,radarlabWriter_1,track,radarlabWriter_2,task1,task2,task3,radarlabWriter_3);
    REGISTER_INSTANCES(pythontask);
}
